package com.yrk.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
@WebListener
public class SessionAttrListener implements HttpSessionAttributeListener {
    @Override
    public void attributeAdded(HttpSessionBindingEvent httpSessionBindingEvent) {
        System.out.println("SessionId: " + httpSessionBindingEvent.getSession().getId());
        System.out.println("新增的属性是："+httpSessionBindingEvent.getName()+"值是："+httpSessionBindingEvent.getValue());
    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent httpSessionBindingEvent) {
        System.out.println("SessionId: " + httpSessionBindingEvent.getSession().getId());
        System.out.println("删除的属性是："+httpSessionBindingEvent.getName()+"值是："+httpSessionBindingEvent.getValue());
    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent httpSessionBindingEvent) {

    }
}
